import { requestPOST } from "@/request";
import { setCategory } from "@/store/reducers/commonCategory";
import { setConcatInfo } from "@/store/reducers/contactInfo";
import { useEffect } from "react";
import { useDispatch } from "react-redux";

export default function useInitStore() {
  const dispatch = useDispatch();

  const initCategoryData = () => {
    requestPOST("index/commonCategory").then((res: any[]) => {
      dispatch(setCategory([{ id: 1, categoryName: "Home" }, ...res]));
    });
  };

  const initConcatInfo = () => {
    requestPOST("other/contactInformation").then((res: any) => {
      dispatch(setConcatInfo(res));
    });
  };
  useEffect(() => {
    initCategoryData();
    initConcatInfo();
  }, []);
}
